package com.bfly.mall.order.dto;

import com.bfly.core.enums.AccessRole;
import com.bfly.mall.order.enums.*;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 退款申请日志列表DTO
 *
 * @author 长沙商脉科技有限公司
 * @date 2020/10/7 23:57
 */
public class OrderRefundListDTO implements Serializable {


    private static final long serialVersionUID = -5148588262407578903L;

    private int id;
    private String refundNo;
    private String orderNo;
    private int opId;
    private String opName;
    private int opType;
    private Date createDate;
    private String applyReason;
    private BigDecimal orderPrice;
    private int status;
    private int progressStatus;
    private BigDecimal refundPrice;
    private String remark;

    private int orderStatus;
    private int payStatus;
    private int expressStatus;
    private int payType;

    /**
     * 门店是否能做退款确认操作
     * 订单打开状态，支付待退款状态，待发货状态 可以申请退款
     * 订单打开状态，支付待退款状态，已发货状态 可以申请退款
     * 订单完成状态，支付待退款状态，已收货状态 可以申请退款
     * 订单完成状态，支付待退款状态，商家已收货状态 可以申请退款
     *
     * @author 长沙商脉科技有限公司
     * @date 2020/4/25 18:31
     */
    public boolean isCanRefund() {
        return (getOrderStatus() == OrderStatusEnum.OPEN.getId() && getPayStatus() == PayStatusEnum.WAIT_REFUND.getId() && getExpressStatus() == ExpressStatusEnum.WAIT_SHIP.getId()) ||
                (getOrderStatus() == OrderStatusEnum.OPEN.getId() && getPayStatus() == PayStatusEnum.WAIT_REFUND.getId() && getExpressStatus() == ExpressStatusEnum.SHIPPING.getId()) ||
                (getOrderStatus() == OrderStatusEnum.COMPLETE.getId() && getPayStatus() == PayStatusEnum.WAIT_REFUND.getId() && getExpressStatus() == ExpressStatusEnum.RECEIVED.getId()) ||
                (getOrderStatus() == OrderStatusEnum.COMPLETE.getId() && getPayStatus() == PayStatusEnum.WAIT_REFUND.getId() && getExpressStatus() == ExpressStatusEnum.RETURN_RECEIVED.getId());
    }

    /**
     * 门店是否能做驳回退款申请操作
     * 订单打开状态，支付待退款状态，待发货状态 可以驳回申请退款
     * 订单打开状态，支付待退款状态，已发货状态 可以驳回申请退款
     * 订单完成状态，支付待退款状态，已收货状态 可以驳回申请退款
     * 订单完成状态，支付待退款状态，商家已收货状态 可以驳回申请退款
     * 订单完成状态，支付待退款状态，商家待收货状态 可以驳回申请退款
     *
     * @author 长沙商脉科技有限公司
     * @date 2020/4/25 18:55
     */
    public boolean isCanRejectRefund() {
        return isCanRefund() ||
                (getOrderStatus() == OrderStatusEnum.COMPLETE.getId() && getPayStatus() == PayStatusEnum.WAIT_REFUND.getId() && getExpressStatus() == ExpressStatusEnum.RETURN_WAIT_RECEIVE.getId());
    }

    public String getOrderStatusName() {
        OrderStatusEnum status = OrderStatusEnum.getStatus(getOrderStatus());
        return status == null ? "" : status.getName();
    }

    public String getPayStatusName() {
        PayStatusEnum status = PayStatusEnum.getStatus(getPayStatus());
        return status == null ? "" : status.getName();
    }

    public String getExpressStatusName() {
        ExpressStatusEnum status = ExpressStatusEnum.getStatus(getExpressStatus());
        return status == null ? "" : status.getName();
    }

    public String getPayTypeName() {
        PayTypeEnum type = PayTypeEnum.getStatus(getPayType());
        return type == null ? "" : type.getName();
    }

    public String getOpTypeName() {
        AccessRole role = AccessRole.getRole(getOpType());
        return role == null ? "" : role.getName();
    }

    public String getRefundNo() {
        return refundNo;
    }

    public void setRefundNo(String refundNo) {
        this.refundNo = refundNo;
    }

    public String getStatusName() {
        RefundStatusEnum statusEnum = RefundStatusEnum.getStatus(getStatus());
        return statusEnum == null ? "" : statusEnum.getName();
    }

    public String getProgressStatusName() {
        RefundProgressEnum progressEnum = RefundProgressEnum.getStatus(getProgressStatus());
        return progressEnum == null ? "" : progressEnum.getName();
    }

    public int getProgressStatus() {
        return progressStatus;
    }

    public void setProgressStatus(int progressStatus) {
        this.progressStatus = progressStatus;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public BigDecimal getRefundPrice() {
        return refundPrice;
    }

    public void setRefundPrice(BigDecimal refundPrice) {
        this.refundPrice = refundPrice;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getOrderNo() {
        return orderNo;
    }

    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }

    public int getOpId() {
        return opId;
    }

    public void setOpId(int opId) {
        this.opId = opId;
    }

    public String getOpName() {
        return opName;
    }

    public void setOpName(String opName) {
        this.opName = opName;
    }

    public int getOpType() {
        return opType;
    }

    public void setOpType(int opType) {
        this.opType = opType;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public String getApplyReason() {
        return applyReason;
    }

    public void setApplyReason(String applyReason) {
        this.applyReason = applyReason;
    }

    public BigDecimal getOrderPrice() {
        return orderPrice;
    }

    public void setOrderPrice(BigDecimal orderPrice) {
        this.orderPrice = orderPrice;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public int getOrderStatus() {
        return orderStatus;
    }

    public void setOrderStatus(int orderStatus) {
        this.orderStatus = orderStatus;
    }

    public int getPayStatus() {
        return payStatus;
    }

    public void setPayStatus(int payStatus) {
        this.payStatus = payStatus;
    }

    public int getExpressStatus() {
        return expressStatus;
    }

    public void setExpressStatus(int expressStatus) {
        this.expressStatus = expressStatus;
    }

    public int getPayType() {
        return payType;
    }

    public void setPayType(int payType) {
        this.payType = payType;
    }
}
